<template>
  <div class="content">
    <input type="text" v-model="form.nickName" />
    <button @click="saveClick">保存</button>
  </div>
</template>

<script>
import { UPDATA_NAME_AND_PASS } from '@/api'

export default {
  components: {},
  props: {},
  data () {
    return {
      form: {}
    }
  },
  computed: {
    account () {
      return this.$store.state.account
    },
    getUrlForm () {
      return JSON.parse(this.$root.$mp.query.item)
    }
  },
  watch: {},
  created () {},
  mounted () {},
  onShow () {
    this.setFormVlaue()
  },
  methods: {
    setFormVlaue () {
      const vm = this
      vm.form = vm.getUrlForm
    },
    saveClick () {
      const vm = this
      let params = {
        adminId: vm.form.adminId,
        nickName: vm.form.nickName
      }

      UPDATA_NAME_AND_PASS(params)
        .then(r => {
          if (r.data.code === '0' && r.data.data) {
            vm.$alert('保存成功', '').then(() => {
              vm.$router.go(-1)
            })
          } else {
            vm.$toast(r.data.message)
          }
        })
        .catch(e => {
          console.error(e)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'static/styles/color.scss';
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  input {
    width: 90%;
    height: 30px;
    font-size: 14px;
    color: #000;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f2f3f7;
    padding-left: 6px;
    margin: 10px;
  }
  button {
    width: 90%;
    height: 34px;
    border-radius: 25px;
    background: #626efd;
    color: #fff;
    font-size: 14px;
    margin-top: 50px;
  }
}
</style>
